package com.bsj.travel.util;

import lombok.extern.slf4j.Slf4j;

/**
 * @author yinhao
 * @version 1.0
 * @description Lua脚本
 * @date 2023/11/15
 */
@Slf4j
public class LuaScriptUtil {

    /**
     * 删除产品信息，自定义产品主题信息
     * @return 两者返回的数
     */
    public static String delProductInfo() {
        String luaStr = "local product_key = KEYS[1];"
                + "local topic_key = KEYS[2];"
                + "local product_info = ARGV[1];"
                //删除产品缓存
                + "local del_product_count = redis.call('HDEL',product_key,product_info);"
                //删除对应产品自定义主题缓存
                + "local del_product_topic = redis.call('DEL',topic_key);"
                + "local tab = {del_product_count,\"@\",del_product_topic}"
                + "return tostring(tab);";
        return luaStr;
    }
}
